<!DOCTYPE html>
<html>
<!--
Copyright 2011 The Closure Library Authors. All Rights Reserved.

Use of this source code is governed by the Apache License, Version 2.0.
See the COPYING file for details.

-->
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Closure Unit Tests - goog.storage.mechanism.mechanismfactory</title>
<script src="../../base.js"></script>
<script>
  goog.require('goog.storage.mechanism.iterablemechanism_test');
  goog.require('goog.storage.mechanism.prefixedmechanism_test');
  goog.require('goog.storage.mechanism.mechanism_test');
  goog.require('goog.storage.mechanism.mechanismfactory');
  goog.require('goog.testing.jsunit');
</script>
</head>
<body>
<script>

function testBasicOperations() {
  // Test the global mechanism.
  var mechanism = goog.storage.mechanism.mechanismfactory.create();
  if (mechanism) {
    goog.storage.mechanism.mechanism_test.runBasicTests(mechanism);
  }

  // Test some namespace.
  var mechanismNs = goog.storage.mechanism.mechanismfactory.create('foo');
  if (mechanismNs) {
    goog.storage.mechanism.mechanism_test.runBasicTests(mechanismNs);
  }
}

function testIterableOperations() {
  // Test the global mechanism.
  var mechanism = goog.storage.mechanism.mechanismfactory.create();
  if (mechanism) {
    goog.storage.mechanism.iterablemechanism_test.runIterableTests(mechanism);
  }

  // Test some namespace.
  var mechanismNs = goog.storage.mechanism.mechanismfactory.create('foo');
  if (mechanismNs) {
    goog.storage.mechanism.iterablemechanism_test.runIterableTests(mechanismNs);
  }
}

function testSharing() {
  // Test the global mechanism.
  var mechanismA = goog.storage.mechanism.mechanismfactory.create();
  if (mechanismA) {
    var mechanismB = goog.storage.mechanism.mechanismfactory.create();
    assertTrue(!!mechanismB);

    goog.storage.mechanism.prefixedmechanism_test.runSharingTests(
        mechanismA, mechanismB);
  }

  // Test some namespace.
  var mechanismA = goog.storage.mechanism.mechanismfactory.create('foo');
  if (mechanismA) {
    var mechanismB = goog.storage.mechanism.mechanismfactory.create('foo');
    assertTrue(!!mechanismB);

    goog.storage.mechanism.prefixedmechanism_test.runSharingTests(
        mechanismA, mechanismB);
  }
}

function testSeparation() {
  // Test two different namespaces.
  var mechanismA = goog.storage.mechanism.mechanismfactory.create('foo');
  if (mechanismA) {
    var mechanismB = goog.storage.mechanism.mechanismfactory.create('bar');
    assertTrue(!!mechanismB);

    goog.storage.mechanism.prefixedmechanism_test.runSeparationTests(
        mechanismA, mechanismB);
  }
}

</script>
</body>
</html>
